home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / others / ole_101.zip / SCHMOO.ZIP / OLEVTBL.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  7KB  |  279 lines

  1. /*
  2.  * OLEVTBL.C
  3.  *
  4.  * Creates or frees the procedure instances for the server, document,
  5.  * and object VTBLs.  There are two functions for each table:  one
  6.  * to initialize the table, the other to free the instances in the table.
  7.  *
  8.  * Copyright(c) Microsoft Corp. 1992 All Rights Reserved
  9.  *
  10.  */
  11.  
  12.  
  13. #ifdef MAKEOLESERVER
  14.  
  15.  
  16. #include <windows.h>
  17. #include <ole.h>
  18. #include "schmoo.h"
  19. #include "oleglobl.h"
  20.  
  21. //This prevents annoying type warnings for assigning function pointers.
  22. #ifdef MSC700
  23. #pragma warning(disable:4113)
  24. #endif
  25.  
  26.  
  27. /*
  28.  * FOLEVtblInitServer
  29.  *
  30.  * Purpose:
  31.  *  Creates procedure instances for all the OLE methods required
  32.  *  by the server library for standard server methods.
  33.  *
  34.  * Parameters:
  35.  *  hInst           HANDLE of the application instance.
  36.  *  pvt             LPOLESERVERVTBL to the VTBL to initialize.
  37.  *
  38.  * Return Value:
  39.  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
  40.  *
  41.  * Customization:
  42.  *  None required.
  43.  */
  44.  
  45. BOOL FAR PASCAL FOLEVtblInitServer(HANDLE hInst, LPOLESERVERVTBL pvt)
  46.     {
  47.     BOOL        fRet;
  48.  
  49.     pvt->Create            =MakeProcInstance(ServerCreate,             hInst);
  50.     pvt->CreateFromTemplate=MakeProcInstance(ServerCreateFromTemplate, hInst);
  51.     pvt->Edit              =MakeProcInstance(ServerEdit,               hInst);
  52.     pvt->Execute           =MakeProcInstance(ServerExecute,            hInst);
  53.     pvt->Exit              =MakeProcInstance(ServerExit,               hInst);
  54.     pvt->Open              =MakeProcInstance(ServerOpen,               hInst);
  55.     pvt->Release           =MakeProcInstance(ServerRelease,            hInst);
  56.  
  57.     fRet =(NULL!=pvt->Create);
  58.     fRet&=(NULL!=pvt->CreateFromTemplate);
  59.     fRet&=(NULL!=pvt->Edit);
  60.     fRet&=(NULL!=pvt->Execute);
  61.     fRet&=(NULL!=pvt->Exit);
  62.     fRet&=(NULL!=pvt->Open);
  63.     fRet&=(NULL!=pvt->Release);
  64.  
  65.     return fRet;
  66.     }
  67.  
  68.  
  69. /*
  70.  * OLEVtblFreeServer
  71.  *
  72.  * Purpose:
  73.  *  Frees all procedure instances in the server VTBL.
  74.  *
  75.  * Parameters:
  76.  *  pvt             LPOLESERVERVTBL to the VTBL to free.
  77.  *
  78.  * Return Value:
  79.  *  none
  80.  *
  81.  * Customization:
  82.  *  None required.
  83.  */
  84.  
  85. void FAR PASCAL OLEVtblFreeServer(LPOLESERVERVTBL pvt)
  86.     {
  87.     FreeProcInstance(pvt->Create);
  88.     FreeProcInstance(pvt->CreateFromTemplate);
  89.     FreeProcInstance(pvt->Edit);
  90.     FreeProcInstance(pvt->Exit);
  91.     FreeProcInstance(pvt->Open);
  92.     FreeProcInstance(pvt->Release);
  93.  
  94.     return;
  95.     }
  96.  
  97.  
  98.  
  99.  
  100.  
  101. /*
  102.  * FOLEVtblInitDocument
  103.  *
  104.  * Purpose:
  105.  *  Creates procedure instances for all the OLE methods required
  106.  *  for document methods.
  107.  *
  108.  * Parameters:
  109.  *  hInst           HANDLE of the application instance.
  110.  *  pvt             LPOLESERVERDOCVTBL to the VTBL to initialize.
  111.  * 
  112.  * Return Value:
  113.  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
  114.  *
  115.  * Customization:
  116.  *  None required.
  117.  */
  118.  
  119. BOOL FAR PASCAL FOLEVtblInitDocument(HANDLE hInst, LPOLESERVERDOCVTBL pvt)
  120.     {
  121.     BOOL        fRet;
  122.  
  123.     pvt->Close           =MakeProcInstance(DocClose,            hInst);
  124.     pvt->GetObject       =MakeProcInstance(DocGetObject,        hInst);
  125.     pvt->Execute         =MakeProcInstance(DocExecute,          hInst);
  126.     pvt->Release         =MakeProcInstance(DocRelease,          hInst);
  127.     pvt->Save            =MakeProcInstance(DocSave,             hInst);
  128.     pvt->SetColorScheme  =MakeProcInstance(DocSetColorScheme,   hInst);
  129.     pvt->SetDocDimensions=MakeProcInstance(DocSetDocDimensions, hInst);
  130.     pvt->SetHostNames    =MakeProcInstance(DocSetHostNames,     hInst);
  131.  
  132.     fRet =(NULL!=pvt->Close);
  133.     fRet&=(NULL!=pvt->GetObject);
  134.     fRet&=(NULL!=pvt->Execute);
  135.     fRet&=(NULL!=pvt->Release);
  136.     fRet&=(NULL!=pvt->Save);
  137.     fRet&=(NULL!=pvt->SetColorScheme);
  138.     fRet&=(NULL!=pvt->SetDocDimensions);
  139.     fRet&=(NULL!=pvt->SetHostNames);
  140.  
  141.     return fRet;
  142.     }
  143.  
  144.  
  145.  
  146.  
  147. /*
  148.  * OLEVtblFreeDocument
  149.  *
  150.  * Purpose:
  151.  *  Frees all procedure instances in the document VTBL.
  152.  *
  153.  * Parameters:
  154.  *  pvt             LPOLESERVERDOCVTBL to the VTBL to free.
  155.  *
  156.  * Return Value:
  157.  *  none
  158.  *
  159.  * Customization:
  160.  *  None required.
  161.  */
  162.  
  163. void FAR PASCAL OLEVtblFreeDocument(LPOLESERVERDOCVTBL pvt)
  164.     {
  165.     FreeProcInstance(pvt->Close);
  166.     FreeProcInstance(pvt->GetObject);
  167.     FreeProcInstance(pvt->Release);
  168.     FreeProcInstance(pvt->Save);
  169.     FreeProcInstance(pvt->SetColorScheme);
  170.     FreeProcInstance(pvt->SetDocDimensions);
  171.     FreeProcInstance(pvt->SetHostNames);
  172.  
  173.     return;
  174.     }
  175.  
  176.  
  177.  
  178.  
  179.  
  180. /*
  181.  * FOLEVtblInitObject
  182.  *
  183.  * Purpose:
  184.  *  Creates procedure instances for all the OLE methods required
  185.  *  for object methods.
  186.  *
  187.  * Parameters:
  188.  *  hInst           HANDLE of the application instance.
  189.  *  pvt             LPOLEOBJECTVTBL to free.
  190.  * 
  191.  * Return Value:
  192.  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
  193.  *
  194.  * Customization:
  195.  *  Your application might not use global variables for srvrvtbl,
  196.  *  docvtbl, and objvtbl.
  197.  */
  198.  
  199. BOOL FAR PASCAL FOLEVtblInitObject(HANDLE hInst, LPOLEOBJECTVTBL pvt)
  200.     {
  201.     BOOL        fRet;
  202.     FARPROC     lpfn;
  203.     LPVOIDPROC  lpvp;
  204.  
  205.     /*
  206.      * Local variables are used here just to make this one assignment
  207.      * more readable since it requires some typecasting to compile clean
  208.      * at warning level 3.
  209.      */
  210.     lpfn=(FARPROC)ObjQueryProtocol;
  211.     lpvp=(LPVOIDPROC)MakeProcInstance(lpfn, hInst);
  212.  
  213.     pvt->QueryProtocol  = lpvp;
  214.     pvt->DoVerb         =MakeProcInstance(ObjDoVerb,           hInst);
  215.     pvt->EnumFormats    =MakeProcInstance(ObjEnumFormats,      hInst);
  216.     pvt->GetData        =MakeProcInstance(ObjGetData,          hInst);
  217.     pvt->Release        =MakeProcInstance(ObjRelease,          hInst);
  218.     pvt->SetBounds      =MakeProcInstance(ObjSetBounds,        hInst);
  219.     pvt->SetColorScheme =MakeProcInstance(ObjSetColorScheme,   hInst);
  220.     pvt->SetData        =MakeProcInstance(ObjSetData,          hInst);
  221.     pvt->SetTargetDevice=MakeProcInstance(ObjSetTargetDevice,  hInst);
  222.     pvt->Show           =MakeProcInstance(ObjShow,             hInst);
  223.  
  224.  
  225.  
  226.     fRet =(NULL!=pvt->QueryProtocol);
  227.     fRet&=(NULL!=pvt->DoVerb);
  228.     fRet&=(NULL!=pvt->EnumFormats);
  229.     fRet&=(NULL!=pvt->GetData);
  230.     fRet&=(NULL!=pvt->Release);
  231.     fRet&=(NULL!=pvt->SetBounds);
  232.     fRet =(NULL!=pvt->SetColorScheme);
  233.     fRet&=(NULL!=pvt->SetData);
  234.     fRet&=(NULL!=pvt->SetTargetDevice);
  235.     fRet&=(NULL!=pvt->Show);
  236.  
  237.     return fRet;
  238.     }
  239.  
  240.  
  241.  
  242.  
  243.  
  244. /*
  245.  * OLEVtblFreeObject
  246.  *
  247.  * Purpose:
  248.  *  Frees all procedure instances in the object VTBL.
  249.  *
  250.  * Parameters:
  251.  *  pvt             LPOLEOBJECTVTBL to the VTBL to free.
  252.  *
  253.  * Return Value:
  254.  *  none
  255.  *
  256.  * Customization:
  257.  *  None required.
  258.  */
  259.  
  260. void FAR PASCAL OLEVtblFreeObject(LPOLEOBJECTVTBL pvt)
  261.     {
  262.     FreeProcInstance(pvt->DoVerb);
  263.     FreeProcInstance(pvt->EnumFormats);
  264.     FreeProcInstance(pvt->GetData);
  265.     FreeProcInstance((FARPROC)pvt->QueryProtocol);
  266.     FreeProcInstance(pvt->Release);
  267.     FreeProcInstance(pvt->SetBounds);
  268.     FreeProcInstance(pvt->SetColorScheme);
  269.     FreeProcInstance(pvt->SetData);
  270.     FreeProcInstance(pvt->SetTargetDevice);
  271.     FreeProcInstance(pvt->Show);
  272.  
  273.     return;
  274.     }
  275.  
  276.  
  277.  
  278. #endif //MAKEOLESERVER
  279.